package com.dgut.common.mapper;

import com.dgut.common.entity.Attachment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dgut.common.vo.AttachmentVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author it00zyq
 * @since 2021-04-04
 */
@Repository
public interface AttachmentMapper extends BaseMapper<Attachment> {

    /**
     * 附件列表
     * @param id 日记ID
     * @return 日记附件列表
     */
    @Select("select a.id, a.file_name, a.file_url, a.size from attachment as a where a.type = 2 and a.deleted = 0 and a.diary_id = #{id}")
    List<AttachmentVO> listDiaryAttachById(@Param("id") Integer id);

}
